﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using KBC_Quiz_Show.Bussiness;
using System.Data.SqlClient;
using System.Collections;
using KBC_Quiz_Show.Object;


namespace KBC_Quiz_Show.Presentation
{
    public partial class FrmLogin : DevComponents.DotNetBar.Office2007RibbonForm
    {
        ArrayList list;
        AdminController adminControl = new AdminController();
        Admin admin = new Admin();
        public FrmLogin()
        {
            InitializeComponent();
        }

        
        public void login()
        {
            list = adminControl.LoadAmin();
            String username = txtUsername.Text;
            String pass = txtPass.Text;
            foreach (Admin i in list)
            {
                String user = i.username;
                String password = i.pass;
                if (username.CompareTo(user) == 0 && pass.CompareTo(password) == 0)
                {
                    Form1 frmMain = new Form1();
                    MessageBox.Show("Welcome" + username.ToUpper() + "to System!");
                    frmMain.frmChangePass.txtUserName.Text = username;
                    frmMain.Visible = true;
                    frmMain.ShowForm();
                    frmMain.Show();
                    this.Close();
                    break;
                } else

                {
                    MessageBox.Show("Please enter username and password again !");
                    break;
                }

            }
            
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            this.login();

        }

        

        private void btnCancel_Click_1(object sender, EventArgs e)
        {
            this.Dispose();
        }
    }
}
